<template name="templateSettings">
  <div class="panel panel-default">
    <div class="panel-body">
      <div class="col-md-12">
        {{> React templateGrid }}
      </div>
    </div>
  </div>

  {{#if instance.state.get 'isEditing'}}
    {{#if instance.state.get 'editingId'}}
      {{#if typeEmail}}
        <div>
          {{#autoForm
            collection=Collections.Templates
            doc=template
            id="email-template-edit-form"
            meteormethod="templates/email/update"
            schema=emailTemplateSchema
            template="bootstrap3-inline"
            type="method-update"
            validation="none"
          }}

            <div class="panel panel-default">
              <div class="panel-heading" data-i18n="templateUpdateForm.emailTemplates.updateEmailTemplate">Update email template</div>
              <div class="panel-body">
                <div class="col-md-12 form-group">
                  {{>afQuickField name="title" class="form-control"}}
                  {{>afQuickField name="name" class="form-control" disabled=true}}
                  {{>afQuickField name="language" class="form-control" disabled=true}}
                  {{>afQuickField name="subject" class="form-control"}}
                  {{>afQuickField name="template" label="HTML" class="form-control" type="textarea" rows="15"}}
                </div>
              </div>

              <div class="panel-footer">
                <div class="right">
                  <div class="clearfix">
                    <div class="pull-right">
                      <button type="button" class="btn btn-primary cancel" data-i18n="app.cancel">Cancel</button>
                      <button type="submit" class="btn btn-primary" data-i18n="app.saveChanges">Save Changes</button>
                    </div>
                  </div>
                </div>
              </div>
            </div>

          {{/autoForm}}
        </div>
      {{else}}
      <div>
        <div class="panel panel-default">
          <div class="panel-heading" data-i18n="templateUpdateForm.reactTemplates.updateReactTemplate">Update React template</div>
          <div class="panel-body">
            <div class="col-md-12">
              <div class="alert alert-info">
                <span data-i18n="templateUpdateForm.reactTemplates.updateUnavailable">React templates cannot be edited through this interface</span>
              </div>
            </div>
          </div>
        </div>
      </div>
      {{/if}}
    {{/if}}
  {{/if}}
</template>
